home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Description:
- // This script is executed when a new scene file is created. It will create
- // panels if required or use existing panels.
- //
- // Creation Date: Dec 1998
- // Author: APP
- //
- global proc string unShareBrush( )
- {
- // No arguments. Takes selection list and makes all strokes
- // which share the same brush use different brushes.
- // Returns the name of the last brush made.
-
- string $nodes[] = `getStrokes 2`;
- string $node;
- string $brushes[];
- int $bIdx = 0;
-
- if (size( $nodes ) == 0) {
- // No strokes were found, quit.
- warning("No paths are in the selection list to unshare brushes - need multiple paths - no action taken.");
- return "";
- }
- if (size( $nodes ) == 1) {
- // Only one stroke was found, quit.
- warning("Only 1 path is on the selection list to unshare brushes - need multiple paths - no action taken.");
- return "";
- }
- for ($node in $nodes) {
- string $attr = $node + ".brush";
- string $result = `connectionInfo -sfd $attr`;
- string $buffer[];
- int $num = `tokenize $result "." $buffer`;
- $brushes[ $bIdx ] = $buffer[0];
- ++$bIdx;
- }
-
- // Loop over the nodes in the strokes brushes list and any that have duplicates, create a new brush, and attach.
- $i = 0;
- string $createdBrush = "";
- while ($i < $bIdx) {
- // Get the current brush.
- string $target = $brushes[$i];
- int $j = $i + 1;
- // Now look through the rest of the brushes looking for a brush of the same name.
- while ($j < $bIdx) {
- if ($brushes[$j] == $target) {
- // We found a duplicate. Duplicate the $target brush and reconnect the appropriate node.
- string $newBrush[] = `duplicate -ic $target`;
- string $attrDst = $nodes[ $j ] + ".brush";
- string $attrSrc = $newBrush[0] + ".outBrush";
- connectAttr -f $attrSrc $attrDst;
- $j = $bIdx; // break out of this inner loop
- }
- $j = $j + 1;
- }
- $i = $i + 1;
- }
-
- return $createdBrush;
- }
-